/*
 * Main.fx
 *
 * Created on 03/02/2010, 8:28:26 PM
 */

package org.frapwidgets;

import javafx.stage.Stage;

/**
 * @author jsm
 */

import javafx.scene.control.Label;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.Reflection;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import org.jfxtras.scene.ResizableScene;
import org.jfxtras.scene.layout.MigLayout;
import org.jfxtras.scene.layout.MigLayout.*;

import org.frapwidgets.scene.control.hud.HudButton;
import org.frapwidgets.scene.shape.demo.NewDemoContainer;


def hudFont = Font.font("sans", FontWeight.EXTRA_BOLD, 10);
def reflection = Reflection {
  fraction: 1
  topOffset: 5
}
def normalLabel = Label {
  text: "Normal style"
  font: hudFont
  textFill: Color.WHITE
}
def normalButton = HudButton {
  text: "Demo"
  effect: reflection
}
def strongLabel = Label {
  text: "Strong style"
  font: hudFont
  textFill: Color.WHITE
}
def strongButton = HudButton {
  text: "Demo"
  strong: true
  effect: reflection
}
def disabledLabel = Label {
  text: "Disabled"
  font: hudFont
  textFill: Color.WHITE
}
def disabledButton = HudButton {
  text: "Demo"
  disable: true
  effect: reflection
}
def imageLabel = Label {
  text: "Image"
  font: hudFont
  textFill: Color.WHITE
}
def imageButton = HudButton {
  arcDiam: 8
  graphic: ImageView {
    translateX: 1 // nudge to the right for aesthetics
    image: Image { url: "{__DIR__}eyedropper.png" }
  }
  effect: reflection
}

def buttonDemo = MigLayout {
  constraints: "fill"
  rows: "[grow][]para[][grow]"
  content: [
    migNode( VBox { }, "wrap" ),
    migNode( normalLabel, "alignx center" ),
    migNode( strongLabel, "alignx center" ),
    migNode( disabledLabel, "alignx center" ),
    migNode( imageLabel, "alignx center, wrap"),
    migNode( normalButton, "alignx center, aligny bottom" ),
    migNode( strongButton, "alignx center, aligny bottom" ),
    migNode( disabledButton, "alignx center, aligny bottom" ),
    migNode( imageButton, "alignx center, aligny bottom, w 24, h 20, wrap" ),
    migNode( VBox { }, "wrap")
  ]
}


Stage {
  title: "HUD Buttons"
  //style: StageStyle.TRANSPARENT

  def demo = NewDemoContainer {
    contentNode: buttonDemo
    background: LinearGradient {
      endX: 0, proportional: true
      stops: [
        Stop { color: Color.color(0.2, 0.2, 0.2, 0.9) },
        Stop { offset: 1.0, color: Color.color(0.05, 0.05, 0.05, 0.9) }
      ]
    }
    effect: DropShadow {
      offsetX: 5
      offsetY: 5
      radius: 5
      color: Color.color(0, 0, 0, 0.5)
    }
  }

  scene: ResizableScene {
    fill: null
    width: 500
    height: 130
    content: MigLayout {
      constraints: "fill"
      content: [
        migNode(demo, "pos 0% 0% (100% - 10px) (100% - 10px)")
      ]
    }
  }

}